<?php
class TaskformAction extends CommonAction {
	
	
	public function _initialize(){
		parent::_initialize();
		$this->dao = D('Form');
	}
	
	
	
	function index(){
		$this->listmap = 1;
		$this->listmap .= ' and tf.site_id = '.$this -> siteid;
		parent::_list('tf','left join __FORMCATEGORY__ as fc on fc.id=tf.formcategory_id','tf.*,fc.name as categoryname');
		$this->display();
	}	
	
	//重新编辑方法
	public function edit(){
		$id = $this->_get('id');//获取表单的ID
		//查询该表单下的字段表的集合数据
		$Field = M('Field');
		$fields = $Field ->where(array('form_id' => $id)) -> select();
		$this -> assign('list',$fields);//渲染字段数据集
		//查询该表单的详细信息
		$Form = M('form');
		
		$res = $Form ->where(array('id'=>$id)) ->find();
		$res['approver'] = trim($res['approver'],',');
		$res['rule'] = trim($res['ruleids'],',');
		
		
		
		$this->InteType = M('Integral_type') -> where(array('site_id' => $this -> siteid)) -> select();
		
		
		$this->formcategory = M('Formcategory') -> where(array('site_id' => $this->siteid)) -> order('sort, id desc') -> select();
		
		
		//dump($res);
		$this -> assign('form',$res);
		parent::edit();	
	}
	
	
	public function update(){
		$_POST['approver'] = ','.implode(',',$_POST['member_id']).',';
		$_POST['approvername'] = implode(',',$_POST['member_name']);
		
		
		
		$_POST['ruleids'] = ','.implode(',',$_POST['rule_id']).',';
		
		
		
		parent::update(array(), U('index'));
	}
	
	//判断表单的数据信息 以做出判断输出在表单模块中
	
}
